use super::*;
use errors::*;
pub struct VoicemeeterRecorder<'a> {
remote: &'a VoicemeeterRemote,
}
impl<'a> VoicemeeterRecorder<'a> {
#[doc(hidden)]
pub fn new(remote: &'a VoicemeeterRemote) -> Self {
VoicemeeterRecorder { remote }
}
pub fn param(&self, dot: impl Display) -> Cow<'static, ParameterNameRef> {
Cow::Owned(format!("{RECORDER}.{}", dot).into())
}
pub fn stop(&self) -> BoolParameter {
BoolParameter::new(self.param("stop"), self.remote)
}
pub fn play(&self) -> BoolParameter {
BoolParameter::new(self.param("play"), self.remote)
}
pub fn replay(&self) -> BoolParameter {
BoolParameter::new(self.param("replay"), self.remote)
}
pub fn ff(&self) -> BoolParameter {
BoolParameter::new(self.param("ff"), self.remote)
}
pub fn rew(&self) -> BoolParameter {
BoolParameter::new(self.param("rew"), self.remote)
}
pub fn goto(&self) -> StringParameter {
StringParameter::new(self.param("goto"), self.remote)
}
pub fn out_bus_assignation(&self, bus: &Device) -> Result<BoolParameter, ParameterError> {
if !bus.is_bus() {
return Err(InvalidTypeError::ExpectedBus {
device: format!("{:?}", bus),
}
.into());
}
Ok(BoolParameter::new(
self.param(
bus.as_bus_index(&self.remote.program)
.ok_or(DeviceError {
program: self.remote.program,
device: *bus,
})?
.1,
),
self.remote,
))
}
pub fn record(&self) -> BoolParameter {
BoolParameter::new(self.param("record"), self.remote)
}
pub fn pause(&self) -> BoolParameter {
BoolParameter::new(self.param("pause"), self.remote)
}
pub fn load(&self) -> StringParameter<'a, true, false> {
StringParameter::new(self.param("load"), self.remote)
}
pub fn samplerate(&self) -> IntParameter {
IntParameter::new(self.param("samplerate"), self.remote, 0..=2)
}
pub fn arm_strip(&self, strip: impl StripIndex) -> Result<BoolParameter, ParameterError> {
Ok(BoolParameter::new(
self.param(format_args!(
"ArmStrip({})",
strip.into_strip_index(&self.remote.program)?
)),
self.remote,
))
}
pub fn arm_bus(&self, bus: impl BusIndex) -> Result<BoolParameter, ParameterError> {
Ok(BoolParameter::new(
self.param(format_args!(
"ArmBus({})",
bus.into_bus_index(&self.remote.program)?
)),
self.remote,
))
}
pub fn mode(&self) -> VoicemeeterRecorderMode<'a> {
VoicemeeterRecorderMode::new(self.remote)
}
pub fn bit_resolution(&self) -> IntParameter {
IntParameter::new(self.param("bitResolution"), self.remote, 8..=32)
}
pub fn channel(&self) -> IntParameter {
IntParameter::new(self.param("Channel"), self.remote, 1..=8)
}
pub fn kbps(&self) -> IntParameter {
IntParameter::new(self.param("kbps"), self.remote, 32..=320)
}
pub fn file_type(&self) -> IntParameter {
IntParameter::new(self.param("FileType"), self.remote, 1..=100)
}
pub fn gain(&self) -> FloatParameter {
FloatParameter::new(self.param("gain"), self.remote, -60.0..=12.0)
}
}
pub struct VoicemeeterRecorderMode<'a> {
remote: &'a VoicemeeterRemote,
}
impl<'a> VoicemeeterRecorderMode<'a> {
fn new(remote: &'a VoicemeeterRemote) -> Self {
VoicemeeterRecorderMode { remote }
}
pub fn param(&self, dot: impl Display) -> Cow<'static, ParameterNameRef> {
Cow::Owned(format!("{RECORDER}.mode.{}", dot).into())
}
pub fn recbus(&self) -> BoolParameter {
BoolParameter::new(self.param("recbus"), self.remote)
}
pub fn play_on_load(&self) -> BoolParameter {
BoolParameter::new(self.param("PlayOnLoad"), self.remote)
}
pub fn loop_(&self) -> BoolParameter {
BoolParameter::new(self.param("Loop"), self.remote)
}
pub fn multi_track(&self) -> BoolParameter {
BoolParameter::new(self.param("MultiTrack"), self.remote)
}
}